package com.hzncc.flowable_diboot.project_contracts.dto;

import com.diboot.core.binding.query.BindQuery;
import com.diboot.core.binding.query.Comparison;
import com.diboot.iam.entity.IamOrg;
import com.diboot.iam.entity.IamUser;
import com.hzncc.flowable_diboot.project_contracts.entity.ProjectContractItem;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

        import com.hzncc.flowable_diboot.project_contracts.entity.ProjectContractAudit;
/**
* 项目类合同合同项目 DTO定义
*
* @author MyName
* @version 1.0
* @date 2024-09-24
 * Copyright © MyCorp
*/
@Getter
@Setter
@Accessors(chain = true)
public class ProjectContractItemDTO extends ProjectContractItem  {
private static final long serialVersionUID = 1946164286244690923L;

        /**
        * 序号 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "serial_number")
        private Long serialNumberBegin;

        /**
        * 序号 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "serial_number")
        private Long serialNumberEnd;
        /**
        * 数量 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "quantity")
        private BigDecimal quantityBegin;

        /**
        * 数量 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "quantity")
        private BigDecimal quantityEnd;
        /**
        * 销售单价 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "sales_unit_price")
        private BigDecimal salesUnitPriceBegin;

        /**
        * 销售单价 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "sales_unit_price")
        private BigDecimal salesUnitPriceEnd;
        /**
        * 销售总价 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "sales_total_price")
        private BigDecimal salesTotalPriceBegin;

        /**
        * 销售总价 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "sales_total_price")
        private BigDecimal salesTotalPriceEnd;
        /**
        * 销售询价 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "sales_inquiry")
        private BigDecimal salesInquiryBegin;

        /**
        * 销售询价 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "sales_inquiry")
        private BigDecimal salesInquiryEnd;
        /**
        * 采购单价 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "purchase_unit_price")
        private BigDecimal purchaseUnitPriceBegin;

        /**
        * 采购单价 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "purchase_unit_price")
        private BigDecimal purchaseUnitPriceEnd;
        /**
        * 采购总价 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "purchase_total_price")
        private BigDecimal purchaseTotalPriceBegin;

        /**
        * 采购总价 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "purchase_total_price")
        private BigDecimal purchaseTotalPriceEnd;
        /**
        * 交货日期
        */
        @BindQuery(comparison = Comparison.GE)
        private LocalDateTime deliveryDate;
        /**
        * 交货日期 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "delivery_date")
        private LocalDate deliveryDateBegin;

        /**
        * 交货日期 截止
        */
        @BindQuery(comparison = Comparison.LT, column = "delivery_date")
        private LocalDate deliveryDateEnd;
        /**
        * 折扣/毛利100% 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "discount")
        private BigDecimal discountBegin;

        /**
        * 折扣/毛利100% 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "discount")
        private BigDecimal discountEnd;
        /**
        * 退税 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "tax_rebate")
        private BigDecimal taxRebateBegin;

        /**
        * 退税 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "tax_rebate")
        private BigDecimal taxRebateEnd;
        /**
        * 退税后毛利率 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "gross_profit_rate_after_tax_rebate")
        private BigDecimal grossProfitRateAfterTaxRebateBegin;

        /**
        * 退税后毛利率 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "gross_profit_rate_after_tax_rebate")
        private BigDecimal grossProfitRateAfterTaxRebateEnd;
        /**
        * 创建时间
        */
        @BindQuery(comparison = Comparison.GE)
        private LocalDateTime createTime;
        /**
        * 创建时间 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "create_time")
        private LocalDate createTimeBegin;

        /**
        * 创建时间 截止
        */
        @BindQuery(comparison = Comparison.LT, column = "create_time")
        private LocalDate createTimeEnd;
        /**
        * 更新时间
        */
        @BindQuery(comparison = Comparison.GE)
        private LocalDateTime updateTime;
        /**
        * 更新时间 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "update_time")
        private LocalDate updateTimeBegin;

        /**
        * 更新时间 截止
        */
        @BindQuery(comparison = Comparison.LT, column = "update_time")
        private LocalDate updateTimeEnd;

        public LocalDate getDeliveryDateEnd() {
            if (getDeliveryDate() != null) {
                return getDeliveryDate().plusDays(1).toLocalDate();
            }
            if (deliveryDateEnd != null) {
                return deliveryDateEnd.plusDays(1);
            }
            return null;
        }
        public LocalDate getCreateTimeEnd() {
            if (getCreateTime() != null) {
                return getCreateTime().plusDays(1).toLocalDate();
            }
            if (createTimeEnd != null) {
                return createTimeEnd.plusDays(1);
            }
            return null;
        }
        public LocalDate getUpdateTimeEnd() {
            if (getUpdateTime() != null) {
                return getUpdateTime().plusDays(1).toLocalDate();
            }
            if (updateTimeEnd != null) {
                return updateTimeEnd.plusDays(1);
            }
            return null;
        }

}